home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / CHOOSECO.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  174 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //
  7. // Definition of Choose Color Common Dialog class
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_CHOOSECO_H)
  10. #define OWL_CHOOSECO_H
  11.  
  12. #if !defined(OWL_COMMDIAL_H)
  13. # include <owl/commdial.h>
  14. #endif
  15. #if !defined(WINSYS_COLOR_H)
  16. # include <winsys/color.h>
  17. #endif
  18.  
  19. #if defined(BI_NAMESPACE)
  20. namespace OWL {
  21. #endif
  22.  
  23. // Generic definitions/compiler options (eg. alignment) preceeding the 
  24. // definition of classes
  25. #include <services/preclass.h>
  26.  
  27. //
  28. // class TChooseColorDialog
  29. // ~~~~~ ~~~~~~~~~~~~~~~~~~
  30. // Wrapper for the Choose-Color common dialog.
  31. //
  32. class _OWLCLASS TChooseColorDialog : public TCommonDialog {
  33.   public:
  34.     class _OWLCLASS TData {
  35.       public:
  36.         TData(uint32 flags = 0, bool allocCustColor = false);
  37.         TData(uint32 flags, const TColor& initColor, 
  38.               bool allocCustColors = false);
  39.  
  40.         uint32              Flags;
  41.         uint32              Error;
  42.         TColor              Color;
  43.         TColor*             CustColors;
  44.  
  45.       protected:
  46.         TAPointer<TColor>   CustColorsArray;  
  47.     };
  48.  
  49.     TChooseColorDialog(TWindow*        parent,
  50.                        TData&          data,
  51.                        TResId          templateId = 0,
  52.                        const char far* title = 0,
  53.                        TModule*        module = 0);
  54.    ~TChooseColorDialog();
  55.  
  56.     // Set the current RGB color in this dialog
  57.     //
  58.     void    SetRGBColor(const TColor& color);
  59.  
  60.   protected:
  61.     TData&  GetData();
  62.     void    SetData(TData& data);
  63.  
  64.     CHOOSECOLOR&  GetCC();
  65.     void   SetCC(const CHOOSECOLOR& cc);
  66.  
  67.     int     DoExecute();
  68.     bool    DialogFunction(uint message, TParam1, TParam2);
  69.  
  70.     // Default behavior inline for message response functions
  71.     //
  72.     TParam2  EvSetRGBColor(TParam1, TParam2);      // EV_REGISTERED(SETRGBSTRING,
  73.  
  74.     // Registered messages this class sends (to itself)
  75.     //
  76.     static uint SetRGBMsgId;
  77.  
  78.   protected_data:
  79.     union {
  80.       CHOOSECOLOR  Cc;  // New name
  81.       CHOOSECOLOR  cc;  // Old name
  82.     };
  83.     TData&       Data;
  84.  
  85.   private:
  86.     TChooseColorDialog(const TChooseColorDialog&);
  87.     TChooseColorDialog& operator=(const TChooseColorDialog&);
  88.  
  89.   DECLARE_RESPONSE_TABLE(TChooseColorDialog);
  90.   DECLARE_CASTABLE;
  91. };
  92.  
  93. // Generic definitions/compiler options (eg. alignment) following the 
  94. // definition of classes
  95. #include <services/posclass.h>
  96.  
  97. #if defined(BI_NAMESPACE)
  98. } // namespace OWL
  99. #endif
  100.  
  101. //----------------------------------------------------------------------------
  102. // Inline implementations
  103. //
  104.  
  105. //
  106. // Set the current selection to a specific RGB color.
  107. //
  108. inline void TChooseColorDialog::SetRGBColor(const TColor& color) {
  109.   SendMessage(SetRGBMsgId, 0, color);
  110. }
  111.  
  112. //
  113. // Return the data object for this common dialog.
  114. //
  115. inline TChooseColorDialog::TData& TChooseColorDialog::GetData() {
  116.   return Data;
  117. }
  118.  
  119. //
  120. // Set the data for this common dialog.
  121. // Use this function with caution!
  122. //
  123. inline void TChooseColorDialog::SetData(TData& data) {
  124.   Data = data;
  125. }
  126.  
  127. //
  128. // Return the CHOOSECOLOR data structure for this dialog.
  129. //
  130. inline CHOOSECOLOR& TChooseColorDialog::GetCC() {
  131.   return Cc;
  132. }
  133.  
  134. //
  135. // Set the CHOOSECOLOR data structure for this dialog.
  136. // Use this function with caution!
  137. //
  138. inline void TChooseColorDialog::SetCC(const CHOOSECOLOR& cc) {
  139.   Cc = cc;
  140. }
  141.  
  142. //
  143. // The user has clicked on a color.
  144. //
  145. inline TParam2 TChooseColorDialog::EvSetRGBColor(TParam1, TParam2) {
  146.   return DefaultProcessing();
  147. }
  148.  
  149. //
  150. //
  151. //
  152. inline TChooseColorDialog::TData::TData(uint32 flags, bool allocCustColor) {
  153.   Flags = 0;  
  154.   if (allocCustColor) {
  155.     CustColorsArray = new TColor[16];
  156.     CustColors = CustColorsArray;
  157.   }
  158. }
  159.  
  160. //
  161. //
  162. //
  163. inline TChooseColorDialog::TData::TData(uint32 flags, 
  164.                                         const TColor& initColor, 
  165.                                         bool allocCustColor) {
  166.   Flags = flags;
  167.   Color = initColor;  
  168.   if (allocCustColor) {
  169.     CustColorsArray = new TColor[16];
  170.     CustColors = CustColorsArray;
  171.   }
  172. }
  173. #endif  // OWL_CHOOSECO_H
  174.